﻿namespace LeetCode_Learn
{
    /// <summary>
    /// 获取一个奇数
    /// </summary>
    public class Part03_GetOneOddNumber
    {
        public static int Get(int[] arr)
        {
            if (arr == null)
                throw new ArgumentNullException("arr不可为空!");
            if (arr.Length < 2)
                return arr[0];

            int eor = 0;
            for (int i = 0; i < arr.Length; i++)
            {
                eor ^= arr[i];
            }

            return eor;
        }
    }
}
